﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Optimization.Optimizer
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            Optimizer.exe -help
            Optimizer.exe -cmd=listproblems -output=problems.xml
            Optimizer.exe -cmd=listsolvers -output=solvers.xml
            Optimizer.exe -cmd=execute -input=experiment001.xml -output=experiment002.xml -parallelismlevel=8
            Optimizer.exe -cmd=compile -input=demoproblem.cs -output=demoproblem.dll
            Optimizer.exe -cmd=exportcsv -input=experiment001.xml -output=experiment001.csv
        */

            if (args.Length == 1) 
                if (args[0] == "-help")
            {
                Console.WriteLine("Optimizer.exe -help");

                Console.WriteLine("Optimizer.exe -cmd=listproblems -output=problems.xml");
                Console.WriteLine("Optimizer.exe -cmd=listsolvers -output=solvers.xml");
                Console.WriteLine("Optimizer.exe -cmd=execute -input=experiment001.xml -output=experiment002.xml -parallelismlevel=8");
                Console.WriteLine("Optimizer.exe -cmd=compile -input=demoproblem.cs -output=demoproblem.dll");
                Console.WriteLine("Optimizer.exe -cmd=exportcsv -input=experiment001.xml -output=experiment001.csv");

                return;
            }

            string cmd = "";
            cmd = "-cmd=execute";
            cmd = args.First((s) => (s.StartsWith("-cmd")));
            cmd = cmd.Replace("-cmd=", "");

            CommandExecutor ce = new CommandExecutor();

            //Optimizer.exe -cmd=execute -input=MichalExperimentsBase_C.xml -output=MichalResults.xml -parallelismlevel=4

            //cmd = "plantseeds";
            //args = new string[] { "-cmd=definesteps", "-input=_MProbsBase.xml", "-output=_MProbsBase_B.xml", "-steps=0" };
            //args = new string[] { "-cmd=plantseeds", "-input=_MProbsBase_B.xml", "-output=_MProbsBase_C.xml", "-seedcount=1" };
            //args = new string[] { "-cmd=execute", "-input=_MProbsBase_C.xml", "-output=_MProbsBaseResults.xml", "-parallelismlevel=1"};
            //cmd = "execute";
            ce.Run(cmd, args);
            
        }
    }
}
